package com.sell.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.sell.dataobject.OrderDetail;
import com.sell.enums.OrderStatusEnum;
import com.sell.enums.PayStatusEnum;
import com.sell.utils.EnumUtil;
import com.sell.utils.serializer.Data2LongSerializer;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @Author: megan
 * @Data: 2018/12/4 9:34 PM
 * @Description: 订单dto
 */
@Data
//@JsonInclude(JsonInclude.Include.NON_NULL)
public class OrderDTO {
    /**
     * 订单id
     */
    private String orderId;

    /**
     * 买家名称
     */
    private String buyerName;

    /**
     * 买家手机号
     */
    private String buyerPhone;

    /**
     * 买家手机号
     */
    private String buyerAddress;

    /**
     * 买家微信openid
     */
    private String buyerOpenid;

    /**
     * 订单金额
     */
    private BigDecimal orderAmount;

    /**
     * 订单状态 默认为0 新订单
     */
    private Integer orderStatus;

    /**
     * 支付状态 默认为0 未支付
     */
    private Integer payStatus;

    /**
     * 订单创建时间
     */
    @JsonSerialize(using = Data2LongSerializer.class)
    private Date createTime;

    /**
     * 订单修改时间
     */
    @JsonSerialize(using = Data2LongSerializer.class)
    private Date updateTime;

    /**
     * 订单详情
     */
    List<OrderDetail> orderDetailList;

    /**
     * 订单状态
     *
     * @return
     */
    @JsonInclude
    public OrderStatusEnum getOrderStatusEnum() {
        return EnumUtil.getByCode(orderStatus, OrderStatusEnum.class);
    }

    /**
     * 支付状态
     *
     * @return
     */
    @JsonInclude
    public PayStatusEnum getPayStatusEnum() {
        return EnumUtil.getByCode(payStatus, PayStatusEnum.class);
    }
}
